-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[wip][LLD] Support RISCV vendor-specific relocations. #168497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@lenary for feedback |
🐧 Linux x64 Test Results
|
lenary
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the iterator, it seems clean and a sensible wrapper for the logic.
I have more feedback about the bitfields, at the moment, but overall I'm happy with the direction so far.
I haven't yet had to think about dynamic relocations, and if they have some differences compared to the existing design/spec (are local symbols a problem here?)
| auto riscvVendorString = getRISCVVendorString(reloc.type); | ||
| if (ctx.arg.emachine == llvm::ELF::EM_RISCV && riscvVendorString) { | ||
| Symbol &vendorSym = *ctx.symtab->addSymbol(Defined{ | ||
| ctx, ctx.internalFile, *riscvVendorString, llvm::ELF::STB_GLOBAL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ctx, ctx.internalFile, *riscvVendorString, llvm::ELF::STB_GLOBAL, | |
| ctx, ctx.internalFile, *riscvVendorString, llvm::ELF::STB_LOCAL, |
I think we've said these need to be local, but maybe that's not right for dynamic relocs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I recalled that dynamic relocations could only point to global symbols, but I'm failing to find that requirement in the ELF spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oracle docs seem to agree with you:
The .dynsym table begins with the standard NULL symbol, followed by the files global symbols. STT_FILE symbols are typically not present in this symbol table. STT_SECTION symbols might be present if required by relocation entries.
From: https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-79797.html#stlac
I will go back to the ABI about this. We made them local to echo mapping symbols, but evidently that doesn't work for vendor-specific dynamic relocations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Can you share the ABI discussion link once you bring it there?
lenary
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems clear to me what's going on (though I've implemented this once already). I would be happy to help review/maintain this code if it was landed.
One Nit below.
Do we want to make sure we never parse a relocation from a file that's more than 255? They would have had to have been made deliberately, but are possible to encode on rv64. It's the sort of error that's useful to have and remove in the future, if the abi ever gets so many relocations.
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
458904f to
2b9e004
Compare
This is an implentation of RISCV vendor-specific relocation support in LLD, derived from a working prototype implementation in the downstream CHERIoT repository: CHERIoT-Platform/llvm-project@3d6d6f7
At this time I am seeking design feedback on the shape of the implementation, while I work on developing tests that do not depend on CHERIoT.
Key elements of the design include: